
#include "pointCloud.h"

namespace pc 
{
	

bool PointCloud::loadFromFile(std::string fileName)
{
		
		if (pcl::io::loadPCDFile<pcl::PointXYZRGB> ("s.pcd", *_cloud) == -1) //* load the file
		  {
			PCL_ERROR ("Couldn't read file test_pcd.pcd \n");
			return (-1);
		  }

		std::cout<<_cloud->width * _cloud->height<<std::endl;
			return true;

}

void PointCloud::draw(RenderState& state)const
{
	glPointSize(2.0f);
	glBegin(GL_POINTS);
	
	for(size_t i = 0;i<_cloud->points.size();i++){

		glColor3f(_cloud->points[i].r/255.0,_cloud->points[i].g/255.0,_cloud->points[i].b/255.0);
		glVertex3f(_cloud->points[i].x,_cloud->points[i].y,_cloud->points[i].z);

	}

	glEnd();

}

}